Skip to content

Add UIImage/NSImage ImageProvider implementation#822

Merged
Kyle-Ye merged 8 commits intomainfrom
feature/vector_image_layer
Mar 14, 2026
Merged

Add UIImage/NSImage ImageProvider implementation#822
Kyle-Ye merged 8 commits intomainfrom
feature/vector_image_layer

Conversation

@Kyle-Ye
Copy link
Collaborator

@Kyle-Ye Kyle-Ye commented Mar 14, 2026

Summary

  • Implement UIImage._resolve(in:) matching SwiftUI binary behavior: orientation conversion, contents extraction (CGImage/IOSurface), symbol image layout metrics with content insets, unrotated pixel size computation, rendering mode mapping, and resizing info
  • Implement NSImage.resolve(in:) with correct displayScale-based pixel size computation and VectorImageLayer contents
  • Add GraphicsImage.image(with:variableValue:at:) for named/system/private-system image lookup
  • Add private UIKit API declarations: _hasImageAsset, ioSurface, contentInsets, imageNamed:inBundle:, _systemImageNamed: variants

Test plan

  • Verify UIImage-based Image rendering on iOS simulator
  • Verify NSImage-based Image rendering on macOS
  • Test symbol image layout metrics (SF Symbols with content insets)
  • Test image orientation handling for all 8 UIImage.Orientation cases
  • Test IOSurface-backed image contents extraction

@augmentcode
Copy link

augmentcode bot commented Mar 14, 2026

🤖 Augment PR Summary

Summary: Adds platform image-provider support for UIImage and NSImage, aiming to match SwiftUI’s runtime image resolution behavior.

Changes:

  • Add Image(uiImage:) / Image(nsImage:) convenience initializers and make UIImage/NSImage conform to ImageProvider.
  • Implement UIImage resolution to extract contents (CGImage/IOSurface), map orientation/rendering mode, compute unrotated pixel size, and attach symbol layout metrics + cap-inset resizing info.
  • Implement NSImage resolution with display-scale-based pixel sizing, VectorImageLayer-backed contents, and accessibility description fallback handling.
  • Add a macOS VectorImageLayer adapter that converts NSImage into an ORBDisplayList for vector-layer rendering.
  • Add a UITraitCollection helper to resolve UIImageAsset variants using environment-derived traits.
  • Introduce SPI/private UIKit/AppKit shims for image-asset detection, IOSurface/contentInsets access, and internal image lookup APIs.
  • Exclude AppKit conversions/tests from macCatalyst builds.
  • Update pinned revisions in Package.resolved for dependent packages.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

}

private var resizingInfo: Image.ResizingInfo? {
guard capInsets != .zero else { return nil }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This guard capInsets != .zero drops resizingInfo even when resizingMode == .tile, which can lose tiling behavior for images created with zero insets (e.g. resizableImage(withCapInsets: .zero, resizingMode: .tile)). Consider ensuring tile-mode images still produce a non-nil Image.ResizingInfo.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@codecov
Copy link

codecov bot commented Mar 14, 2026

Codecov Report

❌ Patch coverage is 2.98507% with 65 lines in your changes missing coverage. Please review.
✅ Project coverage is 27.46%. Comparing base (410618c) to head (b768307).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...rces/OpenSwiftUI/View/Image/VectorImageLayer.swift 0.00% 34 Missing ⚠️
...es/OpenSwiftUI/View/Image/NSImageConversions.swift 6.66% 28 Missing ⚠️
...penSwiftUICore/View/Text/Text/Text+Localized.swift 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #822      +/-   ##
==========================================
- Coverage   27.47%   27.46%   -0.02%     
==========================================
  Files         661      663       +2     
  Lines       42444    42510      +66     
==========================================
+ Hits        11663    11675      +12     
- Misses      30781    30835      +54     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions bot added the test Test related issue label Mar 14, 2026
@Kyle-Ye Kyle-Ye force-pushed the feature/vector_image_layer branch from b36c69c to a705f8b Compare March 14, 2026 10:33
@Kyle-Ye Kyle-Ye force-pushed the feature/vector_image_layer branch from a705f8b to b768307 Compare March 14, 2026 13:31
@Kyle-Ye Kyle-Ye merged commit b1ac85f into main Mar 14, 2026
9 of 12 checks passed
@Kyle-Ye Kyle-Ye deleted the feature/vector_image_layer branch March 14, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request platform: iOS platform: macOS test Test related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant